package de.karlNet.sambamanager.ldapController.commands.macros;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Controller;

import de.karlNet.sambamanager.ldapController.commands.AddUserToGroup;
import de.karlNet.sambamanager.ldapController.commands.BaseCommand;
import de.karlNet.sambamanager.ldapController.commands.CreateUser;
import de.karlNet.sambamanager.ldapModel.dto.LdapUserCreationDTO;

@Controller
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class CreateUserMacro extends BaseCommand {
	@Autowired
	private CreateUser userCreationCommand;
	@Autowired
	private AddUserToGroup addUserToGroup;

	public void createUser(LdapUserCreationDTO ldapUserCreationDTO)
			throws UnsupportedEncodingException {
		this.userCreationCommand.createUserItself(ldapUserCreationDTO
				.getLdapUser());
		this.addUserToGroup.addUserToGroupItself(ldapUserCreationDTO);
		this.resetTrees();

	}
}
